<script src="__INDEX__/js/jquery-1.11.3.min.js?v=1.0.0"></script>
<script src="__INDEX__/js/swiper.min.js?v=1.0.0"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script src="__COMMON__/layui/layui.js"></script>
<script src="__INDEX__/js/index.min.js?v=1.0.1"></script>

<script>

    var rate = null;
    var layer = null;
    
    layui.use(['rate', 'layer'], function(){
        rate = layui.rate;
        layer = layui.layer;
    });

    /**
     * 打开投票弹窗
     * @author Meng
     * @dateTime 2020-12-08
     * @return   {[type]}   [description]
     */
    function openVotePopup(id, aid) {
        layer.open({
            type: 2,
            anim: 2,
            closeBtn: 0,
            move: false,
            title: false,
            offset: 'lb',
            shadeClose: true,
            area: ['100vw', '50vh'],
            content: '{:url("/index/index/vote")}?id=' + id + '&aid=' + aid,
        });
    }

    /**
     * 用户登录
     * @author Meng
     * @dateTime 2020-12-08
     * @return   {[type]}   [description]
     */
    function doLogin() {
        var nickname = $('#nickname').val();
        console.log('nickname---->', nickname);
        if (!nickname) {
            layer.msg('请输入花名');
            $('#nickname').focus();
            return;
        }

        var url = '{:url("login/login")}';
        var data = {
            nickname
        };
        $.post(url, data, function(result) {
            layer.msg(result.msg);
            if (result.code === 1) {
                setTimeout(function() {
                    window.location.reload();
                }, 1000);
            } else {
                $('#nickname').focus();
            }
        });
    }

    /**
     * 退出登录
     * @author Meng
     * @dateTime 2020-12-08
     * @return   {[type]}   [description]
     */
    function doLogout() {
        var url = '{:url("login/logout")}';
        var data = {};
        $.post(url, data, function(result) {
            layer.msg(result.msg);
            if (result.code === 1) {
                window.location.reload();
            }
        });
    }
    
</script>